import numpy as np

lidar_range = 1.0

lidar_scan = np.array([.1, .1, 0.1, 1, 1, 1, 1, 1, 1], dtype=np.float32)

reward_safety_static = np.log(lidar_scan).mean()

print(reward_safety_static)

print(np.linalg.norm(lidar_scan, ord=2))

print(np.arccos(0))

a = np.array([-1, -1])

b = np.array([5, 0])

theta = np.arccos(np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)))

print(f'theta: {theta}')

print(np.arccos(1))

# 计算点积
dot_product_ab = np.dot(a, b)
dot_product_bb = np.dot(b, b)

# 计算投影
proj_a_on_b = (dot_product_ab / dot_product_bb) * b

# 计算模长
norm_a = np.linalg.norm(a)
norm_proj_a_on_b = np.linalg.norm(proj_a_on_b)

# 计算比值
ratio = norm_proj_a_on_b / norm_a
print(f'ratio: {ratio}')